import re


class RayElectricity:

    # "光缆", "电缆", "钢绞线", "电杆", "钢缆", "电源线"
    def __init__(self, sel, inse):
        self.sel = sel
        self.inse = inse

    def select(self):
        if self.sel in ("光缆"):
            if self.select1() in ("拆除"):
                return 147
            elif self.select1() in ("新|敷|铺"):
                if self.select3() == 144:
                    if self.select2() in ("架空"):
                        return 5
                    elif self.select2() in ("管道"):
                        return 8
                    elif self.select2() in ("楼内"):
                        return 7
                else:
                    if self.select2() in ("架空"):
                        return 5
                    elif self.select2() in ("管道"):
                        return 6
                    elif self.select2() in ("楼内"):
                        return 7
        elif self.sel in ("电缆"):
            if self.select1() in ("拆除"):
                return 147
            elif self.select1() in ("新|敷|铺"):
                if self.select2() in ("架空"):
                    # print(self.select4())
                    return 5

                elif self.select2() in ("管道"):
                    return 6
                elif self.select2() in ("楼内"):
                    return 7
        elif self.sel in ("钢绞线", "钢缆"):
            if self.select1() in ("拆除"):
                return 146
            elif self.select1() in ("新|敷|铺"):
                return 2
        elif self.sel in ("电杆"):
            if self.select1() in ("拆除"):
                return 145
            elif self.select1() in ("新|敷|铺"):
                if self.select5() in ("七米"):
                    return 150
                elif self.select5() in ("八米"):
                    return 151
                elif self.select5() in ("九米"):
                    return 152
        elif self.sel in ("电源线"):
            if self.select2() in ("架空"):
                return 11
            elif self.select2() in ("管道"):
                return 12
            elif self.select2() in ("楼内"):
                return 13

    """该方法判断电杆的规格"""

    def select5(self):
        try:
            sel = re.findall("七米|八米|九米", self.inse)[0]
            return sel
        except:
            return "八米"

    """该方法判断电缆线的规格"""

    def select4(self):
        sel = re.findall("-\d*", self.inse)[0]
        return sel

    """该方法判断拆除还是新铺设"""

    def select1(self):
        try:
            sel = re.findall("拆除|敷|铺|新", self.inse)[0]
            return sel
        except:
            return "新"

    """该方法判断架空楼内还是管道"""

    def select2(self):
        sel = re.findall("架空|管道|楼内", self.inse)[0]
        return sel

    """该方法读取光缆芯数"""

    def select3(self):
        sel = re.findall("\d*D|\d*芯|\d*d", self.inse)[0]
        yy = int(re.split("D|d|芯", sel)[0])
        return yy

    def getRayElectricity(self):
        return self.select()
